public class Solution125 {
    /**
     * 验证回文串
     * 输入: "A man, a plan, a canal: Panama"
     * 输出: true
     */
    public boolean isPalindrome(String s) {
        if (s == null || s.length() == 0 || s.length() == 1) return true;
        char[] array = s.toCharArray();
        int l = 0, r = array.length - 1;
        while (l <= r) {
            if (array[l] < 48 || (array[l] > 57 && array[l] < 65) || (array[l] > 90 && array[l] < 97) || array[l] > 122) {
                l++;
                continue;
            }
            if (array[r] < 48 || (array[r] > 57 && array[r] < 65) || (array[r] > 90 && array[r] < 97) || array[r] > 122) {
                r--;
                continue;
            }

            if (array[l] <= 57 && array[r] > 57) return false;
            if (array[l] > 57 && array[r] <= 57) return false;
            if (array[l] != array[r] && array[l] + 32 != array[r] && array[l] != array[r] + 32) return false;
            l++;
            r--;
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println('a' - 0);
        System.out.println('z' - 0);
        System.out.println('A' - 0);
        System.out.println('Z' - 0);
        System.out.println('0' - 0);
        System.out.println('9' - 0);
    }
}
